package Practice;

import java.util.Scanner;

public class Asking {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),m = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        for (int j = 0; j < m; j++) {
            int x = sc.nextInt();
            System.out.println(arr[x-1]);
        }
        sc.close();
    }
}
